package tedu.api.collection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

public class CollectionToArray {
    public static void main(String[] args) {
        Collection<String> c = new ArrayList<>();
        c.add("1");
        c.add("2");
        c.add("3");
        c.add("4");
        c.add("5");
        System.out.println(c);

        //若参数数组元素个数<=集合的个数，正常转换
        //若参数数组元素个数>集合的个数，会在末尾补上多出的个数，并赋默认值
        String[] arr = c.toArray(new String[0]);
        System.out.println(Arrays.toString(arr));

    }
}
